package cn.tedu.micro.service.stock.mapper;

import cn.tedu.micro.service.pojo.po.StockPO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface StockMapper extends BaseMapper<StockPO> {
    //目前sql语句比较复杂，MP满足不了需求，所以定义扩展的方法
    @Update("update stock_tbl set stock=stock-#{count} where " +
            " product_code=#{productCode} and stock>#{count}")
    Integer reduceStock(@Param("productCode") String productCode,@Param("count") Integer count);
}
